/*
 * @Date: 2025-07-21 23:24:53
 * @LastEditors: 贾二小 erxiao.jia@outlook.com
 * @LastEditTime: 2025-07-21 23:25:05
 * @FilePath: /admin-vue/src/composables/useBoolean.ts
 */
import { ref } from 'vue'

/**
 * Boolean
 *
 * @param initValue Init value
 */
export default function useBoolean(initValue = false) {
  const bool = ref(initValue)

  function setBool(value: boolean) {
    bool.value = value
  }
  function setTrue() {
    setBool(true)
  }
  function setFalse() {
    setBool(false)
  }
  function toggle() {
    setBool(!bool.value)
  }

  return {
    bool,
    setBool,
    setTrue,
    setFalse,
    toggle,
  }
}
